package beans;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import org.jboss.logging.Logger;
import org.primefaces.event.FlowEvent;

import model.LoginUsuario;

public class HomeMain {

	private LoginUsuario loginusuario = new LoginUsuario();

	private boolean skip;

	private static Logger logger = Logger.getLogger(HomeMain.class.getName());

	public LoginUsuario getLoginusuario() {
		return loginusuario;
	}

	public void setLoginusuario(LoginUsuario loginusuario) {
		this.loginusuario = loginusuario;
	}

	public void save(ActionEvent actionEvent) {
		// Persist user

		FacesMessage msg = new FacesMessage("Salvo",
				"Dados salvos com sucesso!");
		FacesContext.getCurrentInstance().addMessage(null, msg);
	}

	public boolean isSkip() {
		return skip;
	}

	public void setSkip(boolean skip) {
		this.skip = skip;
	}

	public String onFlowProcess(FlowEvent event) {
		logger.info("Current wizard step:" + event.getOldStep());
		logger.info("Next step:" + event.getNewStep());

		if (skip) {
			skip = false; // reset in case user goes back
			return "confirm";
		} else {
			return event.getNewStep();
		}
	}
}